/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author lomanda
 */
@Entity
@Table(name = "justificacao")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Justificacao.findAll", query = "SELECT j FROM Justificacao j"),
    @NamedQuery(name = "Justificacao.findByIdJustificacao", query = "SELECT j FROM Justificacao j WHERE j.idJustificacao = :idJustificacao"),
    @NamedQuery(name = "Justificacao.findByDetalhes", query = "SELECT j FROM Justificacao j WHERE j.detalhes = :detalhes"),
    @NamedQuery(name = "Justificacao.findByDataInicial", query = "SELECT j FROM Justificacao j WHERE j.dataInicial = :dataInicial"),
    @NamedQuery(name = "Justificacao.findByDataFinal", query = "SELECT j FROM Justificacao j WHERE j.dataFinal = :dataFinal")})
public class Justificacao implements Serializable {
    @Basic(optional = false)
    @NotNull
    @Column(name = "dataInicial")
    @Temporal(TemporalType.DATE)
    private Date dataInicial;
    @Basic(optional = false)
    @NotNull
    @Column(name = "dataFinal")
    @Temporal(TemporalType.DATE)
    private Date dataFinal;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idJustificacao")
    private Integer idJustificacao;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(name = "detalhes")
    private String detalhes;
    @JoinTable(name = "justificacaoAssiduidade", joinColumns = {
        @JoinColumn(name = "fkJustificacao", referencedColumnName = "idJustificacao")}, inverseJoinColumns = {
        @JoinColumn(name = "fkAssiduidade", referencedColumnName = "idAssiduidade")})
    @ManyToMany
    private List<Assiduidade> assiduidadeList;

    public Justificacao() {
    }

    public Justificacao(Integer idJustificacao) {
        this.idJustificacao = idJustificacao;
    }

    public Justificacao(Integer idJustificacao, String detalhes, Date dataInicial, Date dataFinal) {
        this.idJustificacao = idJustificacao;
        this.detalhes = detalhes;
        this.dataInicial = dataInicial;
        this.dataFinal = dataFinal;
    }

    public Integer getIdJustificacao() {
        return idJustificacao;
    }

    public void setIdJustificacao(Integer idJustificacao) {
        this.idJustificacao = idJustificacao;
    }

    public String getDetalhes() {
        return detalhes;
    }

    public void setDetalhes(String detalhes) {
        this.detalhes = detalhes;
    }

    @XmlTransient
    public List<Assiduidade> getAssiduidadeList() {
        return assiduidadeList;
    }

    public void setAssiduidadeList(List<Assiduidade> assiduidadeList) {
        this.assiduidadeList = assiduidadeList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idJustificacao != null ? idJustificacao.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Justificacao)) {
            return false;
        }
        Justificacao other = (Justificacao) object;
        if ((this.idJustificacao == null && other.idJustificacao != null) || (this.idJustificacao != null && !this.idJustificacao.equals(other.idJustificacao))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Justificacao[ idJustificacao=" + idJustificacao + " ]";
    }

    public Date getDataInicial() {
        return dataInicial;
    }

    public void setDataInicial(Date dataInicial) {
        this.dataInicial = dataInicial;
    }

    public Date getDataFinal() {
        return dataFinal;
    }

    public void setDataFinal(Date dataFinal) {
        this.dataFinal = dataFinal;
    }
    
}
